package com.cxria.script.upload.domain;

import com.fasterxml.jackson.annotation.JsonBackReference;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

@Entity
@Table(name = "formatInfo")
class FormatInfo implements Serializable {
    @Id
    @ManyToOne
    @JsonBackReference
    @JoinColumn(name = "videoId")
    Video video;
    @Column
    //@ApiModelProperty("文件大小")
    long size;
    @Column
    //@ApiModelProperty("总时长")
    double duration;
    @Column
    //@ApiModelProperty("文件后缀")
    String extension;
    @Column
    //@ApiModelProperty("格式名称")
    String formatName;
    @Column
    //@ApiModelProperty("流的数量")
    int streams;
    @Column
    //@ApiModelProperty("容器全名")
    String formatLongName;
    @Column
    //@ApiModelProperty("起始时间")
    double startTime;
    @Column
    //@ApiModelProperty("总比特率")
    int bitRate;
    @Column
    //@ApiModelProperty("水印宽")
    int cropWidth;
    @Column
    //@ApiModelProperty("水印高")
    int cropHeight;
    @Column
    //@ApiModelProperty("水印X偏移量")
    int cropX;
    @Column
    //@ApiModelProperty("水印Y偏移量")
    int cropY;

    @Override
    boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        FormatInfo that = (FormatInfo) o;
        return size == that.size &&
                Double.compare(that.duration, duration) == 0 &&
                streams == that.streams &&
                Double.compare(that.startTime, startTime) == 0 &&
                bitRate == that.bitRate &&
                cropWidth == that.cropWidth &&
                cropHeight == that.cropHeight &&
                cropX == that.cropX &&
                cropY == that.cropY &&
                Objects.equals(video, that.video) &&
                Objects.equals(extension, that.extension) &&
                Objects.equals(formatName, that.formatName) &&
                Objects.equals(formatLongName, that.formatLongName);
    }

    @Override
    int hashCode() {
        return Objects.hash(video, size, duration, extension, formatName, streams, formatLongName, startTime, bitRate, cropWidth, cropHeight, cropX, cropY);
    }
}
